<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Ucenter extends CI_Controller {
	
	function index(){
		$user = $this->session->userdata('ych_user');
		if(isset($user['user_id']) && $user['user_id'] > 0){
			//VIP
			$this->load->model('User_vip_model');
			$vipInfo = $this->User_vip_model->get_by_uid($user['user_id']);
			//资金账户
			$this->load->model('Account_model');
			$accountInfo = $this->Account_model->get_account($user['user_id']);
			//积分
			$this->load->model('Credit_model');
			$creditInfo = $this->Credit_model->get_row($user['user_id']);
			//最近回款时间
			$this->load->model('Borrow_model');
			$newlyCollection = $this->Borrow_model->first_collection_time($user['user_id']);
			
			$data['userInfo'] = $user;
			$data['vipTime'] = $vipInfo['vip_verify_time']>0?date('Y-m-d', $vipInfo['vip_verify_time'] + 3600*24*365):'无';
			$data['accountInfo'] = $accountInfo;
			$data['creditValue'] = $creditInfo['credit_value'];
			$data['newCollection'] = $newlyCollection>0?date('Y-m-d', $newlyCollection):'无';
			
			$this->load->view('mobile/account',$data);
			
		}else{
			header('Location: /mobile/login/index/index.html');
		}
	}
	
}